<template>
  <div class="changeRemark">
    <el-dialog
      title="修改备注"
      :visible.sync="isVisible"
      @close="closeDialog"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      :modal-append-to-body="false"
      width="35%"
      center
    >
      <el-form :model="formdata" :rules="rules" ref="formdata" class="demo-ruleForm">
        <el-form-item prop="audit_remark">
          <el-input type="textarea" v-model="formdata.audit_remark" placeholder></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="isVisible = false">取 消</el-button>
        <el-button type="primary" @click="submitForm('formdata')">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { changeRemark } from "@/api/eventManage";
export default {
  name: "changeRemark",
  inject: ["reload"],
  data() {
    return {
      isVisible: this.isShow,
      formdata: {
        audit_remark: this.dialogRow.audit_remark,
        apply_id: this.dialogRow.id,
      },
      rules: {
        audit_remark: [
          { required: true, message: "请输入备注", trigger: "blur" },
        ],
      },
    };
  },
  props: {
    isShow: Boolean,
    dialogRow: Object,
  },
  methods: {
    closeDialog() {
      this.$emit("closeDialog");
    },
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          const para = Object.assign({}, this.formdata);
          changeRemark(para).then((res) => {
            if (res.data.result == 2) {
              this.$message.success("修改成功");
            } else {
              this.$message.error("修改失败");
            }
            setTimeout(() => {
              this.reload();
            }, 20);
            this.isVisible = false;
          });
        }
      });
    },
  },
};
</script>
<style lang="scss">
.changeRemark {
  .el-textarea__inner,
  .el-textarea {
    width: 480px;
    height: 150px;
  }
  .el-textarea__inner {
    resize: none;
  }
  .el-dialog__wrapper .el-form-item {
    margin-bottom: 20px;
  }
}
</style>